package ru.ifmo.sound.jmlbased;

import net.sf.javaml.core.Dataset;
import net.sf.javaml.core.DefaultDataset;
import ru.ifmo.sound.VectorGenerator;
import ru.ifmo.sound.WaveFile;

/**
 * @author avhaliullin
 */
public class DatasetGenerator {
    private SamplesLibrary samplesLibrary;

    public DatasetGenerator(SamplesLibrary samplesLibrary) {
        this.samplesLibrary = samplesLibrary;
    }

    public Dataset generateDataset(int samplesPerTrack) {
        Dataset res = new DefaultDataset();
        for (String className : samplesLibrary.listKnownClasses()) {
            for (WaveFile waveFile : samplesLibrary.getSamples(className)) {
                for (int i = 0; i < samplesPerTrack; i++) {
                    res.add(VectorGenerator.generateInstance(waveFile, className));
                }
            }
        }
        return res;
    }
}
